/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author java
 */
@Entity
@Table(name = "ITEMS")
@NamedQueries({
    @NamedQuery(name = "Item.findAll", query = "SELECT i FROM Item i"),
    @NamedQuery(name = "Item.findById", query = "SELECT i FROM Item i WHERE i.id = :id"),
    @NamedQuery(name = "Item.findByCode", query = "SELECT i FROM Item i WHERE i.code = :code"),
    @NamedQuery(name = "Item.findByName", query = "SELECT i FROM Item i WHERE i.name = :name"),
    @NamedQuery(name = "Item.findByQuantity", query = "SELECT i FROM Item i WHERE i.quantity = :quantity"),
    @NamedQuery(name = "Item.findByAveragePrice", query = "SELECT i FROM Item i WHERE i.averagePrice = :averagePrice"),
    @NamedQuery(name = "Item.findByNeedBarCodeTf", query = "SELECT i FROM Item i WHERE i.needBarCodeTf = :needBarCodeTf"),
    @NamedQuery(name = "Item.findByCompanyId", query = "SELECT i FROM Item i WHERE i.companyId = :companyId"),
    @NamedQuery(name = "Item.findByPurchaseAccId", query = "SELECT i FROM Item i WHERE i.purchaseAccId = :purchaseAccId"),
    @NamedQuery(name = "Item.findBySalesAccId", query = "SELECT i FROM Item i WHERE i.salesAccId = :salesAccId"),
    @NamedQuery(name = "Item.findByCostAccId", query = "SELECT i FROM Item i WHERE i.costAccId = :costAccId"),
    @NamedQuery(name = "Item.findByCardPower", query = "SELECT i FROM Item i WHERE i.cardPower = :cardPower"),
    @NamedQuery(name = "Item.findByItemTypeId", query = "SELECT i FROM Item i WHERE i.itemTypeId = :itemTypeId"),
    @NamedQuery(name = "Item.findByItemDefRetailPrice", query = "SELECT i FROM Item i WHERE i.itemDefRetailPrice = :itemDefRetailPrice"),
    @NamedQuery(name = "Item.findByItemDefMassPrice", query = "SELECT i FROM Item i WHERE i.itemDefMassPrice = :itemDefMassPrice"),
    @NamedQuery(name = "Item.findByItemPricingTypeId", query = "SELECT i FROM Item i WHERE i.itemPricingTypeId = :itemPricingTypeId"),
    @NamedQuery(name = "Item.findBySubscrService", query = "SELECT i FROM Item i WHERE i.subscrService = :subscrService"),
    @NamedQuery(name = "Item.findByRevenueIndicator", query = "SELECT i FROM Item i WHERE i.revenueIndicator = :revenueIndicator"),
    @NamedQuery(name = "Item.findByExpiryDate", query = "SELECT i FROM Item i WHERE i.expiryDate = :expiryDate"),
    @NamedQuery(name = "Item.findByExpiryDateInd", query = "SELECT i FROM Item i WHERE i.expiryDateInd = :expiryDateInd"),
    @NamedQuery(name = "Item.findByUserDefinedField1", query = "SELECT i FROM Item i WHERE i.userDefinedField1 = :userDefinedField1"),
    @NamedQuery(name = "Item.findByUserDefinedField2", query = "SELECT i FROM Item i WHERE i.userDefinedField2 = :userDefinedField2"),
    @NamedQuery(name = "Item.findByUserDefinedField3", query = "SELECT i FROM Item i WHERE i.userDefinedField3 = :userDefinedField3"),
    @NamedQuery(name = "Item.findByUserDefinedField4", query = "SELECT i FROM Item i WHERE i.userDefinedField4 = :userDefinedField4"),
    @NamedQuery(name = "Item.findByUserDefinedField5", query = "SELECT i FROM Item i WHERE i.userDefinedField5 = :userDefinedField5"),
    @NamedQuery(name = "Item.findByUserDefinedField6", query = "SELECT i FROM Item i WHERE i.userDefinedField6 = :userDefinedField6"),
    @NamedQuery(name = "Item.findByItemDefBasicPrice", query = "SELECT i FROM Item i WHERE i.itemDefBasicPrice = :itemDefBasicPrice"),
    @NamedQuery(name = "Item.findByItemDefPurcPrice", query = "SELECT i FROM Item i WHERE i.itemDefPurcPrice = :itemDefPurcPrice"),
    @NamedQuery(name = "Item.findByItemDefHalfMassPrice", query = "SELECT i FROM Item i WHERE i.itemDefHalfMassPrice = :itemDefHalfMassPrice"),
    @NamedQuery(name = "Item.findByItemDefEndUserPrice", query = "SELECT i FROM Item i WHERE i.itemDefEndUserPrice = :itemDefEndUserPrice"),
    @NamedQuery(name = "Item.findBySupId", query = "SELECT i FROM Item i WHERE i.supId = :supId"),
    @NamedQuery(name = "Item.findByReeOrderOpint", query = "SELECT i FROM Item i WHERE i.reeOrderOpint = :reeOrderOpint"),
    @NamedQuery(name = "Item.findByItemStockManTf", query = "SELECT i FROM Item i WHERE i.itemStockManTf = :itemStockManTf"),
    @NamedQuery(name = "Item.findByQuantityWant", query = "SELECT i FROM Item i WHERE i.quantityWant = :quantityWant"),
    @NamedQuery(name = "Item.findByDifQ", query = "SELECT i FROM Item i WHERE i.difQ = :difQ")})

public class Item implements Serializable {
	
	
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    
    @Size(max = 20)
    @Column(name = "CODE")
    private String code;
    
    @Size(max = 50)
    @Column(name = "NAME")
    private String name;
    
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "QUANTITY")
    private Double quantity;
    
    @Column(name = "AVERAGE_PRICE")
    private Double averagePrice;
    
    @Column(name = "NEED_BAR_CODE_TF")
    private Boolean needBarCodeTf;
    
    @Column(name = "COMPANY_ID")
    private Integer companyId;
    
    @Column(name = "PURCHASE_ACC_ID")
    private Integer purchaseAccId;
    
    @Column(name = "SALES_ACC_ID")
    private Integer salesAccId;
    
    @Column(name = "COST_ACC_ID")
    private Integer costAccId;
    
    @Column(name = "CARD_POWER")
    private Double cardPower;
    
    @Column(name = "ITEM_TYPE_ID")
    private Integer itemTypeId;
    
    @Column(name = "ITEM_DEF_RETAIL_PRICE")
    private Double itemDefRetailPrice;
    
    @Column(name = "ITEM_DEF_MASS_PRICE")
    private Double itemDefMassPrice;
    
    @Column(name = "ITEM_PRICING_TYPE_ID")
    private Integer itemPricingTypeId;
    
    @Column(name = "SUBSCR_SERVICE")
    private Integer subscrService;
    
    @Column(name = "REVENUE_INDICATOR")
    private Integer revenueIndicator;
    
    @Column(name = "EXPIRY_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date expiryDate;
    
    @Column(name = "EXPIRY_DATE_IND")
    private Integer expiryDateInd;
    
    @Column(name = "USER_DEFINED_FIELD1")
    private Integer userDefinedField1;
    
    @Column(name = "USER_DEFINED_FIELD2")
    private Integer userDefinedField2;
    
    @Column(name = "USER_DEFINED_FIELD3")
    private Integer userDefinedField3;
    
    @Column(name = "USER_DEFINED_FIELD4")
    private Integer userDefinedField4;
    
    @Column(name = "USER_DEFINED_FIELD5")
    private Integer userDefinedField5;
    
    @Column(name = "USER_DEFINED_FIELD6")
    private Integer userDefinedField6;
    
    @Column(name = "ITEM_DEF_BASIC_PRICE")
    private Double itemDefBasicPrice;
    
    @Column(name = "ITEM_DEF_PURC_PRICE")
    private Double itemDefPurcPrice;
    
    @Column(name = "ITEM_DEF_HALF_MASS_PRICE")
    private Double itemDefHalfMassPrice;
    
    @Column(name = "ITEM_DEF_END_USER_PRICE")
    private Double itemDefEndUserPrice;
    
    @Column(name = "SUP_ID")
    private Integer supId;
    
    @Column(name = "REE_ORDER_OPINT")
    private Double reeOrderOpint;
    
    @Column(name = "ITEM_STOCK_MAN_TF")
    private Boolean itemStockManTf;
    
    @Column(name = "QUANTITY_WANT")
    private Double quantityWant;
    
    @Column(name = "DIF_Q")
    private Double difQ;
    
    @OneToMany(mappedBy = "itemId", fetch = FetchType.LAZY)
    private Set<SaleLine> saleLinesList;

    
    
    public Item() {
    }

    
    public Item(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getQuantity() {
        return quantity;
    }

    public void setQuantity(Double quantity) {
        this.quantity = quantity;
    }

    public Double getAveragePrice() {
        return averagePrice;
    }

    public void setAveragePrice(Double averagePrice) {
        this.averagePrice = averagePrice;
    }

    public Boolean getNeedBarCodeTf() {
        return needBarCodeTf;
    }

    public void setNeedBarCodeTf(Boolean needBarCodeTf) {
        this.needBarCodeTf = needBarCodeTf;
    }

    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public Integer getPurchaseAccId() {
        return purchaseAccId;
    }

    public void setPurchaseAccId(Integer purchaseAccId) {
        this.purchaseAccId = purchaseAccId;
    }

    public Integer getSalesAccId() {
        return salesAccId;
    }

    public void setSalesAccId(Integer salesAccId) {
        this.salesAccId = salesAccId;
    }

    public Integer getCostAccId() {
        return costAccId;
    }

    public void setCostAccId(Integer costAccId) {
        this.costAccId = costAccId;
    }

    public Double getCardPower() {
        return cardPower;
    }

    public void setCardPower(Double cardPower) {
        this.cardPower = cardPower;
    }

    public Integer getItemTypeId() {
        return itemTypeId;
    }

    public void setItemTypeId(Integer itemTypeId) {
        this.itemTypeId = itemTypeId;
    }

    public Double getItemDefRetailPrice() {
        return itemDefRetailPrice;
    }

    public void setItemDefRetailPrice(Double itemDefRetailPrice) {
        this.itemDefRetailPrice = itemDefRetailPrice;
    }

    public Double getItemDefMassPrice() {
        return itemDefMassPrice;
    }

    public void setItemDefMassPrice(Double itemDefMassPrice) {
        this.itemDefMassPrice = itemDefMassPrice;
    }

    public Integer getItemPricingTypeId() {
        return itemPricingTypeId;
    }

    public void setItemPricingTypeId(Integer itemPricingTypeId) {
        this.itemPricingTypeId = itemPricingTypeId;
    }

    public Integer getSubscrService() {
        return subscrService;
    }

    public void setSubscrService(Integer subscrService) {
        this.subscrService = subscrService;
    }

    public Integer getRevenueIndicator() {
        return revenueIndicator;
    }

    public void setRevenueIndicator(Integer revenueIndicator) {
        this.revenueIndicator = revenueIndicator;
    }

    public Date getExpiryDate() {
        return expiryDate;
    }

    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    public Integer getExpiryDateInd() {
        return expiryDateInd;
    }

    public void setExpiryDateInd(Integer expiryDateInd) {
        this.expiryDateInd = expiryDateInd;
    }

    public Integer getUserDefinedField1() {
        return userDefinedField1;
    }

    public void setUserDefinedField1(Integer userDefinedField1) {
        this.userDefinedField1 = userDefinedField1;
    }

    public Integer getUserDefinedField2() {
        return userDefinedField2;
    }

    public void setUserDefinedField2(Integer userDefinedField2) {
        this.userDefinedField2 = userDefinedField2;
    }

    public Integer getUserDefinedField3() {
        return userDefinedField3;
    }

    public void setUserDefinedField3(Integer userDefinedField3) {
        this.userDefinedField3 = userDefinedField3;
    }

    public Integer getUserDefinedField4() {
        return userDefinedField4;
    }

    public void setUserDefinedField4(Integer userDefinedField4) {
        this.userDefinedField4 = userDefinedField4;
    }

    public Integer getUserDefinedField5() {
        return userDefinedField5;
    }

    public void setUserDefinedField5(Integer userDefinedField5) {
        this.userDefinedField5 = userDefinedField5;
    }

    public Integer getUserDefinedField6() {
        return userDefinedField6;
    }

    public void setUserDefinedField6(Integer userDefinedField6) {
        this.userDefinedField6 = userDefinedField6;
    }

    public Double getItemDefBasicPrice() {
        return itemDefBasicPrice;
    }

    public void setItemDefBasicPrice(Double itemDefBasicPrice) {
        this.itemDefBasicPrice = itemDefBasicPrice;
    }

    public Double getItemDefPurcPrice() {
        return itemDefPurcPrice;
    }

    public void setItemDefPurcPrice(Double itemDefPurcPrice) {
        this.itemDefPurcPrice = itemDefPurcPrice;
    }

    public Double getItemDefHalfMassPrice() {
        return itemDefHalfMassPrice;
    }

    public void setItemDefHalfMassPrice(Double itemDefHalfMassPrice) {
        this.itemDefHalfMassPrice = itemDefHalfMassPrice;
    }

    public Double getItemDefEndUserPrice() {
        return itemDefEndUserPrice;
    }

    public void setItemDefEndUserPrice(Double itemDefEndUserPrice) {
        this.itemDefEndUserPrice = itemDefEndUserPrice;
    }

    public Integer getSupId() {
        return supId;
    }

    public void setSupId(Integer supId) {
        this.supId = supId;
    }

    public Double getReeOrderOpint() {
        return reeOrderOpint;
    }

    public void setReeOrderOpint(Double reeOrderOpint) {
        this.reeOrderOpint = reeOrderOpint;
    }

    public Boolean getItemStockManTf() {
        return itemStockManTf;
    }

    public void setItemStockManTf(Boolean itemStockManTf) {
        this.itemStockManTf = itemStockManTf;
    }

    public Double getQuantityWant() {
        return quantityWant;
    }

    public void setQuantityWant(Double quantityWant) {
        this.quantityWant = quantityWant;
    }

    public Double getDifQ() {
        return difQ;
    }

    public void setDifQ(Double difQ) {
        this.difQ = difQ;
    }

    public Set<SaleLine> getSaleLinesList() {
        return saleLinesList;
    }

    public void setSaleLinesList(Set<SaleLine> saleLinesList) {
        this.saleLinesList = saleLinesList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
        
    }
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Item)) {
            return false;
        }
        Item other = (Item) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "entities.Item[ id=" + id + " ]";
    	///System.out.println("came to toString");
    	return getCode() + " " + getName() ;
    	//return id.toString() ;
    }
    
}
